﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace ProjectEulerSolutions.Problems
{
    class Problem110 : IProblem
    {
        public string Calculate()
        {
            //ekstra!

            //D(n) = 1 + sigma[i=1 .. dpi(n)](ji*pi[k=1..i](2*j(i-1) + 1)), gdje je n = p1^j1, p2^j2.. - p su prime faktori, j su im potencije

            long[] primes = new long[] { 2, 3, 5, 7 };

            int[] j = new int[] { 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 };

            Console.WriteLine(D(j));



            BigInteger n = 2 * 2 * 2 * 3 * 3 * 3 * 5 * 5 * 7 * 7 * 11 * 13 * (BigInteger)(17 * 19 * 23) * 29 * 31 * 37;


            //long n = 1;
            //int count = 0;
            //int previousCount = count;
            //for (int j = 0; j < primes.Length && count < 4000000; j++)
            //{
            //    n *= primes[j];
            //    count = 0;
            //    for (long y = n + 1; y <= 2 * n; y++)
            //    {
            //        if (n * y % (y - n) == 0)
            //            count++;
            //    }
            //    Console.WriteLine("{0} \t+{1}", count, count - previousCount);
            //    previousCount = count;
            //    Console.ReadKey();
            //}

            return n.ToString();
        }

        int D(int[] j)
        {
            int count = 1;
            for (int i = 0; i < j.Length; i++)
            {
                int temp = j[i];
                for (int k = 1; k <= i; k++)
                {
                    temp *= 2 * j[k - 1] + 1;
                }
                count += temp;
            }
            return count;
        }
    }
}
